<template>
  <div class="mycommentitem">
    <mycommentitemTwo
      :parent="parent.parent"
      v-if="parent.parent"
    ></mycommentitemTwo>
    <div class="user">
      {{ parent.account.nickname }}
      <i>{{ timestampToTime(parent.created_at) }}</i>
    </div>

    <div class="content">
      <p>{{ parent.content }}</p>
      <div class="imgs" v-for="value in parent.pics" :key="value.id">
        <img :src="'http://157.122.54.189:9095' + value.url" alt="" />
      </div>
      <div class="kong"><span>回复</span></div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["parent"],
  name: "mycommentitemTwo",
  methods: {
    timestampToTime(timestamp) {
      var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
      // let Y = date.getFullYear() + '-';
      // let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
      // let D = date.getDate() + ' ';
      // let h = date.getHours() + ':';
      // let m = date.getMinutes() + ':';
      // let s = date.getSeconds();
      // return Y+this.padLeftZero(M)+this.padLeftZero(D)+this.padLeftZero(h)+this.padLeftZero(m)+this.padLeftZero(s);
      let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? "0" + MM : MM;
      let d = date.getDate();
      d = d < 10 ? "0" + d : d;
      let h = date.getHours();
      h = h < 10 ? "0" + h : h;
      let m = date.getMinutes();
      m = m < 10 ? "0" + m : m;
      let s = date.getSeconds();
      s = s < 10 ? "0" + s : s;
      return y + "-" + MM + "-" + d + " " + h + ":" + m + ":" + s;
    }
  }
};
</script>

<style lang="less" scoped>
.mycommentitem {
  margin: 0 0px 5px;
  padding: 5px 10px 0;
  background-color: #f9f9f9;
  border: 1px solid #ccc;
  .user {
    font-size: 12px;
    color: #666666;
    margin-bottom: 10px;
    img {
      width: 16px;
      height: 16px;
      border-radius: 50%;
      vertical-align: top;
      padding: 0 5px;
    }
    i {
      font-size: 10px;
      color: #999999;
      margin-left: 5px;
    }
  }
  .content {
    padding-left: 30px;
    .imgs {
      margin-top: 10px;
      width: 80px;
      height: 80px;
      padding: 5px;
      margin-right: 10px;
      border: 1px dotted #ddd;
      border-radius: 10%;
      display: inline-block;
      img {
        height: 100%;
        width: 100%;
      }
    }
  }
  .content:hover .kong > span {
    opacity: 1;
  }
  .kong {
    height: 20px;
    text-align: right;
    span {
      opacity: 0;
      font-size: 12px;
      color: #409eff;
      cursor: pointer;
    }
  }
}
</style>
